package yixaun.tim.service.impl;


import yixaun.tim.bean.account.SnsItem;
import yixaun.tim.bean.profile.GenderEnum;
import yixaun.tim.common.TimException;
import yixaun.tim.service.TimProfileService;
import yixaun.tim.service.TimService;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author pengshiqing
 * @Date: 2019/7/26
 * @Description:
 */
public class TimProfileServiceImpl implements TimProfileService {

    private TimService timService;

    public TimProfileServiceImpl(TimService timService) {
        this.timService = timService;
    }


    /**
     * 设置性别
     *
     * @param identifier
     * @param genderEnum
     */
    @Override
    public void setInfoGender(String identifier, GenderEnum genderEnum) throws TimException {

        if (genderEnum == null){
            genderEnum = GenderEnum.Female ;
        }
        String api = "v4/profile/portrait_set";

        Map<String, Object> body = new HashMap<>(4);

        body.put("From_Account", identifier);

        List<SnsItem> list = new ArrayList<>();

        SnsItem snsItem = new SnsItem();
        snsItem.setTag("Tag_Profile_IM_Gender");
        snsItem.setValue(genderEnum.getType());

        list.add(snsItem);
        body.put("ProfileItem",list);

        this.timService.post(api, body);
    }
}
